//
//  UIImageView+MM_Request.m
//  MallManage_IOS
//
//  Created by 张浩 on 2023/12/18.
//

#import "UIImageView+MM_Request.h"

@implementation UIImageView (MM_Request)

- (void)MM_setImageWithUrl:(NSString *)url
          placeholderImage:(UIImage *)placeholder {
    
    //    [self sd_setImageWithURL:[Tools getImgUrlFullPathWithStr:url] placeholderImage:placeholder];
    [self MM_setImageWithUrl:url placeholderImage:placeholder Type:originalImage completed:nil];
}

- (void)MM_setImageWithUrl:(NSString *)url
          placeholderImage:(UIImage *)placeholder
                      Type:(imageType)type {
    
    [self MM_setImageWithUrl:url placeholderImage:placeholder Type:type completed:nil];
}

- (void)MM_setImageWithUrl:(NSString *)url
          placeholderImage:(UIImage *)placeholder
                      Type:(imageType)type
                 completed:(SDExternalCompletionBlock)completedBlock {
    
//    url = [JHHttp getImageFullPathWithPath:url];
//    if ([url containsString:@".upaiyun.com"]&&![url containsString:@"!/fw"]) { // 又拍云
//        switch (type) {
//
//            case heiQulityImage:
//                url = [url stringByAppendingString:@"!/fw/640"];
//                break;
//            case biggerImage:
//                url = [url stringByAppendingString:@"!/fw/240"];
//                break;
//            case middleImage:
//                url = [url stringByAppendingString:@"!/fw/140"];
//                break;
//            case smallImgage:
//                url = [url stringByAppendingString:@"!/fw/50"];
//                break;
//            default:
//                break;
//        }
//    } else if([url hasPrefix:SERVER_IMG]) { /* 我们自己的图片格式**/
//
//        switch (type) {
//
//            case heiQulityImage:
//                url = [url stringByAppendingString:@"_640x640.jpg"];
//                break;
//            case biggerImage:
//                url = [url stringByAppendingString:@"_240x240.jpg"];
//                break;
//            case middleImage:
//                url = [url stringByAppendingString:@"_140x140.jpg"];
//                break;
//            case smallImgage:
//                url = [url stringByAppendingString:@"_50x50.jpg"];
//                break;
//            default:
//                break;
//        }
//    }
//
    
    [self sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:placeholder completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
      
        if (image) {
            
            if (completedBlock) {
                
                completedBlock(image,error,cacheType,imageURL);
            }
        }
    }];
}

@end
